package main

import (
	logger "gitee.com/woodpile/wgs.ths.log.go"
)

var (
	CodeLine     = false
	CodeLineLong = false
)

func main() {
	// CodeLine = true
	// CodeLineLong = true

	logger.DefaultLogger.Config.CodeLine = CodeLine
	logger.DefaultLogger.Config.CodeLineLong = CodeLineLong

	SimpleLine()
	SimpleJson()
}

func SimpleLine() {
	Logger()
}

func SimpleJson() {
	l, err := logger.NewLogger(&logger.LoggerConfig{
		Formatter: logger.DefaultFormatterJson,

		CodeLine:     CodeLine,
		CodeLineLong: CodeLineLong,
	})
	if err != nil {
		panic(err)
	}
	l.Level = logger.LevelInfo
	logger.ResetDefaultLogger(l)

	Logger()
}

func Logger() {
	logger.DBG().Z()
	logger.DBG().Msg("Hello, world!").Z()

	logger.DBG().Pre("long").Msg("Helloooooooooo, world!").Z()
	logger.DBG().Msg("Helloooooooooo, world!").Pre("long").Z()

	logger.DBG().Pre("pre").S("key", "value").Msg("Hello, world!").Z()
	logger.DBG().Pre("pre").I("int", 87).Msg("Hello, world!").Z()
	logger.DBG().Pre("pre").U("uint", 87).Msg("Hello, world!").Z()
	logger.DBG().Pre("pre").D("float", 87.4).Msg("Hello, world!").Z()
	logger.DBG().Pre("pre").I("int", 87).U("uint", 87).D("float", 87.4).S("key", "value").Msg("Hello, world!").Z()
	logger.DBG().
		Pre("pre").
		I("int", 87).U("uint", 87).D("float", 87.4).
		S("key", "value").
		Msg("Hello, world!").Z()
	logger.TRC().Msg("Hello, world!").Z()
	logger.DBG().Msg("Hello, world!").Z()
	logger.INF().Msg("Hello, world!").Z()
	logger.WRN().Msg("Hello, world!").Z()
	logger.ERR().Msg("Hello, world!").Z()
	logger.FAT().Msg("Hello, world!").Z()
}
